<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - global_optimization.cpp</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2017  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font>

<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>global_optimization.h<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>statistics.h<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>sstream<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>string<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>cstdlib<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>ctime<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>vector<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>rand.h<font color='#5555FF'>&gt;</font>

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='tester.h.html'>tester.h</a>"


<font color='#0000FF'>namespace</font>  
<b>{</b>

    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> test;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> dlib;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;

    logger <b><a name='dlog'></a>dlog</b><font face='Lucida Console'>(</font>"<font color='#CC0000'>test.global_optimization</font>"<font face='Lucida Console'>)</font>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='test_upper_bound_function'></a>test_upper_bound_function</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> relative_noise_magnitude, <font color='#0000FF'><u>double</u></font> solver_eps<font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>test_upper_bound_function,  relative_noise_magnitude=</font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> relative_noise_magnitude  <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>, solver_eps=</font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> solver_eps;

        <font color='#0000FF'>auto</font> rosen <font color='#5555FF'>=</font> []<font face='Lucida Console'>(</font><font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> x<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>-</font><font color='#979000'>1</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font> <font color='#979000'>100</font><font color='#5555FF'>*</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#979000'>1</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <b>}</b>;

        dlib::rand rnd;
        <font color='#0000FF'>auto</font> make_rnd <font color='#5555FF'>=</font> [<font color='#5555FF'>&amp;</font>rnd]<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <b>{</b> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font face='Lucida Console'>)</font>; x <font color='#5555FF'>=</font> <font color='#979000'>2</font><font color='#5555FF'>*</font>rnd.<font color='#BB00BB'>get_random_double</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#979000'>2</font><font color='#5555FF'>*</font>rnd.<font color='#BB00BB'>get_random_double</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#0000FF'>return</font> x; <b>}</b>;


        std::vector<font color='#5555FF'>&lt;</font>function_evaluation<font color='#5555FF'>&gt;</font> evals;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> <font color='#979000'>100</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>auto</font> x <font color='#5555FF'>=</font> <font color='#BB00BB'>make_rnd</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            evals.<font color='#BB00BB'>emplace_back</font><font face='Lucida Console'>(</font>x,<font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        upper_bound_function <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>evals, relative_noise_magnitude, solver_eps<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>ub.<font color='#BB00BB'>num_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>evals.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>ub.<font color='#BB00BB'>dimensionality</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font> ev : evals<font face='Lucida Console'>)</font>
        <b>{</b>
            dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y;
            <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y <font color='#5555FF'>&gt;</font> <font color='#5555FF'>-</font><font color='#979000'>1e10</font>, <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y<font face='Lucida Console'>)</font>;
        <b>}</b>


        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> <font color='#979000'>100</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>auto</font> x <font color='#5555FF'>=</font> <font color='#BB00BB'>make_rnd</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            evals.<font color='#BB00BB'>emplace_back</font><font face='Lucida Console'>(</font>x,<font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            ub.<font color='#BB00BB'>add</font><font face='Lucida Console'>(</font>evals.<font color='#BB00BB'>back</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>ub.<font color='#BB00BB'>num_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>evals.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>ub.<font color='#BB00BB'>dimensionality</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font>;

        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font> ev : evals<font face='Lucida Console'>)</font>
        <b>{</b>
            dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y;
            <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y <font color='#5555FF'>&gt;</font> <font color='#5555FF'>-</font><font color='#979000'>1e10</font>, <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>ev.x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> ev.y<font face='Lucida Console'>)</font>;
        <b>}</b>


        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>solver_eps <font color='#5555FF'>&lt;</font> <font color='#979000'>0.001</font><font face='Lucida Console'>)</font>
        <b>{</b>
            dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>out of sample points: </font>";
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> <font color='#979000'>10</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>auto</font> x <font color='#5555FF'>=</font> <font color='#BB00BB'>make_rnd</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#BB00BB'>ub</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font>x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>double</u></font> <b><a name='complex_holder_table'></a>complex_holder_table</b> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>double</u></font> x0, <font color='#0000FF'><u>double</u></font> x1<font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#009900'>// The regular HolderTable function
</font>        <font color='#009900'>//return -std::abs(sin(x0)*cos(x1)*exp(std::abs(1-std::sqrt(x0*x0+x1*x1)/pi)));
</font>
        <font color='#009900'>// My more complex version of it with discontinuities and more local minima.
</font>        <font color='#0000FF'><u>double</u></font> sign <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> j <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>4</font>; j <font color='#5555FF'>&lt;</font> <font color='#979000'>9</font>; j <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#979000'>0.5</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>j <font color='#5555FF'>&lt;</font> x0 <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> x0 <font color='#5555FF'>&lt;</font> j<font color='#5555FF'>+</font><font color='#979000'>0.5</font><font face='Lucida Console'>)</font> 
                x0 <font color='#5555FF'>+</font><font color='#5555FF'>=</font> sign<font color='#5555FF'>*</font><font color='#979000'>0.25</font>;
            sign <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
        <b>}</b>
        <font color='#009900'>// HolderTable function tilted towards 10,10
</font>        <font color='#0000FF'>return</font> <font color='#5555FF'>-</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font><font color='#BB00BB'>sin</font><font face='Lucida Console'>(</font>x0<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>cos</font><font face='Lucida Console'>(</font>x1<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>exp</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font color='#5555FF'>-</font>std::<font color='#BB00BB'>sqrt</font><font face='Lucida Console'>(</font>x0<font color='#5555FF'>*</font>x0<font color='#5555FF'>+</font>x1<font color='#5555FF'>*</font>x1<font face='Lucida Console'>)</font><font color='#5555FF'>/</font>pi<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font><font face='Lucida Console'>(</font>x0<font color='#5555FF'>+</font>x1<font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font color='#979000'>10</font> <font color='#5555FF'>+</font> <font color='#BB00BB'>sin</font><font face='Lucida Console'>(</font>x0<font color='#5555FF'>*</font><font color='#979000'>10</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>cos</font><font face='Lucida Console'>(</font>x1<font color='#5555FF'>*</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='test_global_function_search'></a>test_global_function_search</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
    <b>{</b>

        function_spec spec<b>{</b><b>{</b><font color='#5555FF'>-</font><font color='#979000'>10</font>,<font color='#5555FF'>-</font><font color='#979000'>10</font><b>}</b>, <b>{</b><font color='#979000'>10</font>,<font color='#979000'>10</font><b>}</b><b>}</b>;
        function_spec spec2<b>{</b><b>{</b><font color='#5555FF'>-</font><font color='#979000'>10</font>,<font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#5555FF'>-</font><font color='#979000'>50</font><b>}</b>, <b>{</b><font color='#979000'>10</font>,<font color='#979000'>10</font>, <font color='#979000'>50</font><b>}</b><b>}</b>;
        global_function_search <font color='#BB00BB'>opt</font><font face='Lucida Console'>(</font><b>{</b>spec, spec, spec2<b>}</b><font face='Lucida Console'>)</font>;

        dlib::rand rnd;
        <font color='#0000FF'><u>bool</u></font> found_optimal_point <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> <font color='#979000'>400</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#5555FF'>!</font>found_optimal_point; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            std::vector<font color='#5555FF'>&lt;</font>function_evaluation_request<font color='#5555FF'>&gt;</font> nexts;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> rnd.<font color='#BB00BB'>get_integer_in_range</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>,<font color='#979000'>4</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                nexts.<font color='#BB00BB'>emplace_back</font><font face='Lucida Console'>(</font>opt.<font color='#BB00BB'>get_next_x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font> next : nexts<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>switch</font> <font face='Lucida Console'>(</font>next.<font color='#BB00BB'>function_idx</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>case</font> <font color='#979000'>0</font>: next.<font color='#BB00BB'>set</font><font face='Lucida Console'>(</font> <font color='#5555FF'>-</font><font color='#BB00BB'>complex_holder_table</font><font face='Lucida Console'>(</font>next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <font color='#0000FF'>break</font>;
                    <font color='#0000FF'>case</font> <font color='#979000'>1</font>: next.<font color='#BB00BB'>set</font><font face='Lucida Console'>(</font> <font color='#5555FF'>-</font><font color='#979000'>10</font><font color='#5555FF'>*</font><font color='#BB00BB'>complex_holder_table</font><font face='Lucida Console'>(</font>next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <font color='#0000FF'>break</font>;
                    <font color='#0000FF'>case</font> <font color='#979000'>2</font>: next.<font color='#BB00BB'>set</font><font face='Lucida Console'>(</font> <font color='#5555FF'>-</font><font color='#979000'>2</font><font color='#5555FF'>*</font><font color='#BB00BB'>complex_holder_table</font><font face='Lucida Console'>(</font>next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, next.<font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <font color='#0000FF'>break</font>;
                    <font color='#0000FF'>default</font>: <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font>; <font color='#0000FF'>break</font>;
                <b>}</b>

                matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> x;
                <font color='#0000FF'><u>double</u></font> y;
                <font color='#0000FF'><u>size_t</u></font> function_idx;
                opt.<font color='#BB00BB'>get_best_function_eval</font><font face='Lucida Console'>(</font>x,y,function_idx<font face='Lucida Console'>)</font>;
                <font color='#009900'>/*
                cout &lt;&lt; "\ni: "&lt;&lt; i &lt;&lt; endl;
                cout &lt;&lt; "best eval x: "&lt;&lt; trans(x);
                cout &lt;&lt; "best eval y: "&lt;&lt; y &lt;&lt; endl;
                cout &lt;&lt; "best eval function index: "&lt;&lt; function_idx &lt;&lt; endl;
                */</font>

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>y  <font color='#5555FF'>-</font> <font color='#979000'>10</font><font color='#5555FF'>*</font><font color='#979000'>21.9210397</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>0.0001</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    found_optimal_point <font color='#5555FF'>=</font> <font color='#979000'>true</font>;
                    <font color='#0000FF'>break</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>

        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>found_optimal_point<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='test_find_max_global'></a>test_find_max_global</b><font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>auto</font> rosen <font color='#5555FF'>=</font> []<font face='Lucida Console'>(</font><font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> x<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>-</font><font color='#979000'>1</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font> <font color='#979000'>100</font><font color='#5555FF'>*</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#979000'>1</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <b>}</b>;

        <font color='#0000FF'>auto</font> result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> true_x <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>1</font>,<font color='#979000'>1</font><b>}</b>;

        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font>, std::vector<font color='#5555FF'>&lt;</font>function_evaluation<font color='#5555FF'>&gt;</font><b>{</b><font color='#BB00BB'>function_evaluation</font><font face='Lucida Console'>(</font><b>{</b><font color='#979000'>1.1</font>, <font color='#979000'>0.9</font><b>}</b>, <font color='#BB00BB'>rosen</font><font face='Lucida Console'>(</font><b>{</b><font color='#979000'>1.1</font>, <font color='#979000'>0.9</font><b>}</b><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><b>}</b><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font>, <font color='#979000'>0.0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;


        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <b>{</b><font color='#979000'>false</font>,<font color='#979000'>false</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <b>{</b><font color='#979000'>false</font>,<font color='#979000'>false</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font>, <font color='#979000'>0.0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>0.9</font>, <font color='#979000'>0.9</font><b>}</b>, <b>{</b><font color='#979000'>false</font>,<font color='#979000'>false</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>140</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        true_x <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0.9</font>, <font color='#979000'>0.81</font><b>}</b>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen, bounded at 0.9: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>-</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>10</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.x <font color='#5555FF'>-</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> normal_evals<font color='#5555FF'>=</font><font color='#979000'>0</font>, early_evals<font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#0000FF'>auto</font> normal_result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>[<font color='#5555FF'>&amp;</font>normal_evals]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> normal_evals<font color='#5555FF'>+</font><font color='#5555FF'>+</font>; <font color='#0000FF'>return</font> <font color='#5555FF'>-</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>1</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>10</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2, bound at 1: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>normal_result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>normal_result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>normal_result.x <font color='#5555FF'>-</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>-</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>1</font>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2, bound at 1: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.x <font color='#5555FF'>-</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        constexpr <font color='#0000FF'>auto</font> close_enough <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>16.0</font>;
        <font color='#0000FF'>auto</font> early_result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>[<font color='#5555FF'>&amp;</font>early_evals]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> early_evals<font color='#5555FF'>+</font><font color='#5555FF'>+</font>; <font color='#0000FF'>return</font> <font color='#5555FF'>-</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>1</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>, <font color='#979000'>0.0</font>, std::vector<font color='#5555FF'>&lt;</font>function_evaluation<font color='#5555FF'>&gt;</font><b>{</b><b>}</b>, [<font color='#5555FF'>&amp;</font>]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> y<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> <font face='Lucida Console'>(</font>y <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> close_enough<font face='Lucida Console'>)</font>;<b>}</b><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2, bound at 1: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>early_result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>early_result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>early_result.y<font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>close_enough<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>early_result.x <font color='#5555FF'>-</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>4</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>normal_evals <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> early_evals<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;


        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_max_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> a, <font color='#0000FF'><u>double</u></font> b<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>-</font><font color='#BB00BB'>complex_holder_table</font><font face='Lucida Console'>(</font>a,b<font face='Lucida Console'>)</font>;<b>}</b>, 
            <b>{</b><font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#5555FF'>-</font><font color='#979000'>10</font><b>}</b>, <b>{</b><font color='#979000'>10</font>, <font color='#979000'>10</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>400</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>complex_holder_table y: </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> result.y;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.y  <font color='#5555FF'>-</font> <font color='#979000'>21.9210397</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>0.0001</font>, std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.y  <font color='#5555FF'>-</font> <font color='#979000'>21.9210397</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='test_find_min_global'></a>test_find_min_global</b><font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>auto</font> rosen <font color='#5555FF'>=</font> []<font face='Lucida Console'>(</font><font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> x<font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>+</font><font color='#979000'>1</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font> <font color='#979000'>100</font><font color='#5555FF'>*</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#979000'>1</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>x</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,<font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <b>}</b>;

        <font color='#0000FF'>auto</font> result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> true_x <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>1</font>,<font color='#979000'>1</font><b>}</b>;

        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>5</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0.1</font>, <font color='#979000'>0.1</font><b>}</b>, <b>{</b><font color='#979000'>2</font>, <font color='#979000'>2</font><b>}</b>, <b>{</b><font color='#979000'>false</font>,<font color='#979000'>false</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>rosen, <b>{</b><font color='#979000'>0</font>, <font color='#979000'>0</font><b>}</b>, <b>{</b><font color='#979000'>0.9</font>, <font color='#979000'>0.9</font><b>}</b>, <b>{</b><font color='#979000'>false</font>,<font color='#979000'>false</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>100</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        true_x <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0.9</font>, <font color='#979000'>0.81</font><b>}</b>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>rosen, bounded at 0.9: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font><font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>5</font>, <font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_x<font color='#5555FF'>-</font>result.x<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>10</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.x <font color='#5555FF'>-</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>1</font>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>10</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2, bound at 1: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.x <font color='#5555FF'>-</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> x<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font>x<font color='#5555FF'>-</font><font color='#979000'>2</font>,<font color='#979000'>2.0</font><font face='Lucida Console'>)</font>; <b>}</b>, <font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#979000'>1</font>, std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>(x-2)^2, bound at 1: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>  <font color='#BB00BB'>trans</font><font face='Lucida Console'>(</font>result.x<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>result.x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.x <font color='#5555FF'>-</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>9</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;


        result <font color='#5555FF'>=</font> <font color='#BB00BB'>find_min_global</font><font face='Lucida Console'>(</font>[]<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> a, <font color='#0000FF'><u>double</u></font> b<font face='Lucida Console'>)</font><b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>complex_holder_table</font><font face='Lucida Console'>(</font>a,b<font face='Lucida Console'>)</font>;<b>}</b>, 
            <b>{</b><font color='#5555FF'>-</font><font color='#979000'>10</font>, <font color='#5555FF'>-</font><font color='#979000'>10</font><b>}</b>, <b>{</b><font color='#979000'>10</font>, <font color='#979000'>10</font><b>}</b>, <font color='#BB00BB'>max_function_calls</font><font face='Lucida Console'>(</font><font color='#979000'>400</font><font face='Lucida Console'>)</font>, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        dlog <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> LINFO <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>complex_holder_table y: </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> result.y;
        <font color='#BB00BB'>DLIB_TEST_MSG</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.y  <font color='#5555FF'>+</font> <font color='#979000'>21.9210397</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>0.0001</font>, std::<font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>result.y  <font color='#5555FF'>+</font> <font color='#979000'>21.9210397</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='global_optimization_tester'></a>global_optimization_tester</b> : <font color='#0000FF'>public</font> tester
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <b><a name='global_optimization_tester'></a>global_optimization_tester</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> :
            tester <font face='Lucida Console'>(</font>"<font color='#CC0000'>test_global_optimization</font>",
                    "<font color='#CC0000'>Runs tests on the global optimization components.</font>"<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='perform_test'></a>perform_test</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>test_upper_bound_function</font><font face='Lucida Console'>(</font><font color='#979000'>0.01</font>, <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>6</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>test_upper_bound_function</font><font face='Lucida Console'>(</font><font color='#979000'>0.0</font>, <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>6</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>test_upper_bound_function</font><font face='Lucida Console'>(</font><font color='#979000'>0.0</font>, <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>test_global_function_search</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>test_find_max_global</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>test_find_min_global</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b> a;

<b>}</b>



</pre></body></html>